class Solution {
public:
    int MoreThanHalfNum_Solution(vector<int> numbers) {
        int length = numbers.size();
        if (length == 0)
            return 0;
        sort(numbers.begin(), numbers.end());
        int num = numbers[0];
        int max_count = 1;
        int count = 0;
        for (int i = 1; i < length; i++)
        {
            if (numbers[i] != numbers[i - 1]) {
                if (count > max_count)
                {
                    max_count = count;
                    num = numbers[i - 1];
                }
                count = 1;
            }
            else
            {
                count++;
            }
        }
        if (max_count > length / 2) {
            return num;
        }
        else
            return 0;
    }
};
